package cn.blogsx.array;

/**
 * 数组遍历：就是对数组中的每一个元素，逐一进行访问并做处理
 */
public class Demo09ArrayEach {
    public static void main(String[] args) {
        int [] array= {1,2,3,4,5};
        //原始方式：
        System.out.print(array[0]+ " ");
        System.out.print(array[1]+ " ");
        System.out.print(array[2]+ " ");
        System.out.print(array[3]+ " ");
        System.out.println(array[4]+ " ");

        //for循环
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+ " ");
        }
        //增强for循环
        for (int a: array) {
            System.out.println(a);
        }
    }
}
